﻿package {
	import org.flixel.*;
	
	public class HUD extends FlxGroup {
		private var _text_score:FlxText;
		private var _sprite_tries:FlxGroup;
		private var _num_tries:int;		
		
		public function HUD() {
			_text_score = new FlxText(5, 5, 640, "score: 0");
			add(_text_score);
			
			_sprite_tries = new FlxGroup()
			add(_sprite_tries);
		}
		
		public function setTries(tries:int):void {
			_num_tries = tries;
		}
		
		public function updateScore(score:int):void {
			_text_score.text = "score: " + score;
		}
		
		public function updateTries(tries:int):void {
			_num_tries += tries;
			_sprite_tries.destroy();
			
			for (var i:int = 1; i <= _num_tries; i++) {
				var tmpSprite:FlxSprite = new FlxSprite((22 * i) - 15, 20);
				tmpSprite.alpha = 230;
				tmpSprite.loadGraphic(ResourceManager.triesup);	
				_sprite_tries.add(tmpSprite);
			}
		}
		
		public function getNumTries():int {
			return _num_tries;
		}
		
		override public function update():void {
			super.update();
		}
	}
}